package org.kabeja.parser.entities;

import org.kabeja.dxf.entity.DXFArc;
import org.kabeja.dxf.entity.DXFEntity;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/25 11:15
 */
public class DXFArcHandler extends AbstractEntityHandler {
    public static final String ENTITY_NAME = "ARC";
    public static final int RADIUS = 40;
    public static final int START_ANGLE = 50;
    public static final int END_ANGLE = 51;
    public static final int COUNTERCLOCKWISE = 73;
    private DXFArc arc;

    public DXFArcHandler() {
    }

    @Override
    public void endDXFEntity() {
    }

    @Override
    public DXFEntity getDXFEntity() {
        return this.arc;
    }

    @Override
    public String getDXFEntityName() {
        return "ARC";
    }

    @Override
    public boolean isFollowSequence() {
        return false;
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case 10:
                this.arc.getCenterPoint().setX(var2.getDoubleValue());
                break;
            case 20:
                this.arc.getCenterPoint().setY(var2.getDoubleValue());
                break;
            case 40:
                this.arc.setRadius(var2.getDoubleValue());
                break;
            case 50:
                this.arc.setStartAngle(var2.getDoubleValue());
                break;
            case 51:
                this.arc.setEndAngle(var2.getDoubleValue());
                break;
            case 73:
                this.arc.setCounterClockwise(var2.getBooleanValue());
                break;
            default:
                super.parseCommonProperty(var1, var2, this.arc);
        }

    }

    @Override
    public void parseObject(int var1, DXFValue var2, int type) {
        super.parseObjectProperty(var1, var2, type, this.arc);
    }

    @Override
    public void startDXFEntity() {
        this.arc = new DXFArc();
    }
}
